package com.huangjian.controller;


import com.huangjian.pojo.Order;
import com.huangjian.service.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//提供Restfull服务!!
@RestController
public class OrderController {

    @Autowired
    private OrderServiceImpl orderService;

    @GetMapping("/order/get/{id}")
    public Order getOrder(@PathVariable("id") Integer id) {
        Order order = orderService.queryById(id);
        if (order == null) {
            throw new RuntimeException("Fail");
        }
        return order;
    }

    @GetMapping("/order/list")
    public List<Order> queryAll() {
        return orderService.queryall();
    }

}
